package com.rimi.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;

@Controller
public class UploadController {

    @RequestMapping("/upload4")
    public String upload(@RequestParam MultipartFile file, HttpServletRequest request) throws IOException {
        String name = file.getOriginalFilename();
        String path = request.getServletContext().getRealPath("/video/temp/");
        File f=new File(path);
        if (!f.exists()){
            f.createNewFile();
        }
        System.out.println(name+path);
        file.transferTo(new File(path,name));
        return "uploading_video_2";
    }

}
